package manager;

import java.util.ArrayList;

import model.Chair;
import painter4ViewHelper.Painter;
import painter4ViewHelper.PainterProvider;

public class ChaManager implements PainterProvider {
	
	private ArrayList<Chair> chairs;
	
	public ChaManager() {
		init();
	}

	public void init() {
		chairs = new ArrayList<Chair>();
	}
	
	public Chair getEmptyChair() {
		while (true) {
			for(int i = 0;i < chairs.size();i++) {
				if(chairs.get(i).tryUse()) {
					return chairs.get(i);
				}
			}
		}	
	}
	
	@Override
	public ArrayList<Painter> getPainters() {
		ArrayList<Painter> result = new ArrayList<Painter>();
		for(int i = 0; i < chairs.size(); i++) {
			result.add(chairs.get(i).getPainter());
		}
		return result;
	}

	public int getChairNum() {
		return chairs.size();
	}
	
	public void add(Chair chair) {
		chairs.add(chair);
	}
}
